<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title></title>
    <link rel="stylesheet" href="__STATIC__/css/mui.min.css"/>
    <link rel="stylesheet" href="__STATIC__/css/common.css">
    <link rel="stylesheet" href="__STATIC__/css/module.css"/>
    <link rel="stylesheet" href="__STATIC__/css/mui.picker.min.css"/>
    <script src="__STATIC__/js/jquery.min.js"></script>
    <script src="__STATIC__/js/mui.min.js"></script>
    <script src="__STATIC__/js/mui.picker.min.js"></script>
    <script src="__STATIC__/js/city.data-3.js"></script>


</head>

<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-arrowleft mui-pull-left"></a>
    <h1 class="mui-title">收货地址</h1>
    <button class="mui-btn mui-btn-link mui-link-green mui-pull-right" onclick="baocun();">保存</button>
</header>
<div class="mui-content">
    <form class="fwdz-edit">
        <div class="flex flex-middle">
            <label>收货人</label>
            <input class="flex-1 mui-text-right" id="shouhuo" value="{$arr.realname}" type="text" placeholder="请输入">
        </div>
        <div class="flex flex-middle">
            <label>联系电话</label>
            <input class="flex-1 mui-text-right" id="phone" value="{$arr.mobile}" type="text" placeholder="请输入">
        </div>
        <div class="flex flex-middle">
            <label>所在地区</label>
            <div class="flex-1 mui-text-right city" id="showCityPicker3"><span id="cityResult3">{$arr.city_str}</span></div>
            <input type="hidden" name="dizhi" value="{$arr.address_id}" id="dizhi">
        </div>
        <div class="flex flex-middle">
            <input type="text" id="xiangxi"  value="{$arr.address}" placeholder="详细地址">
        </div>
        <div class="mui-table-view-cell mui-checkbox mart10 bg-fff">
            <input name="checkbox"  id="checkbox-id" type="checkbox" class="color-88b625" {if condition="$arr.status eq 2"} checked {/if} >
            设为默认收货地址
        </div>
    </form>
</div>
<script>
function baocun(){
    var shouhuo = $("#shouhuo").val();
    var phone = $("#phone").val();
    var dizhi = $("#cityResult3").html();
    var xiangxi = $("#xiangxi").val();
    var id = $("#dizhi").val();
    if($('#checkbox-id').is(':checked')) {
    var ty=2;
    }else{
     var ty=1;   
    }
  
    if (shouhuo=='') {alert("请填写姓名");return false;}
    if (phone=='') {alert("请填写电话");return false;}
    if (dizhi=='请选择') {alert("请填写省市区");return false;}
    if (xiangxi=='') {alert("请填写详细地址");return false;}
    url = "{:url('index/User/updizhi')}";
            $.post(url, {shouhuo:shouhuo,phone:phone,dizhi:dizhi,ty:ty,xiangxi:xiangxi,id:id}, function (data) {
                if (data >0) {
                    alert("修改成功");
                    //layer.msg("移除成功", {icon: 1, time: 1000});
                    location.href="{:url('index/User/dizhi')}";
                } else {
                    alert("修改失败");
                }
            })
    
}
    (function($, doc) {
        $.init();
        $.ready(function() {
            var cityPicker3 = new $.PopPicker({
                layer: 3
            });
            cityPicker3.setData(cityData3);
            var showCityPickerButton = doc.getElementById('showCityPicker3');
            var cityResult3 = doc.getElementById('cityResult3');
            showCityPickerButton.addEventListener('tap', function(event) {
                cityPicker3.show(function(items) {
                	
                    cityResult3.innerText =  (items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text;
                    
                    //返回 false 可以阻止选择框的关闭
                    //return false;
                });
            }, false);
        });
    })(mui, document);
</script>
</body>
</html>